Using PID controller to control the orientation of the car!
Start scrolling!The purpose of this lab is to get experience with orientation PID using the IMU. In Lab 5, PID control was done on wall distance using the TOF sensors, this lab will involve controlling the yaw of your robot using the IMU. Like last lab, you can pick whatever controller works best for your system. 4000-level students can choose between P, PI, PID, PD; 5000-level students can choose between PI and PID controllers. Your hand-in will be judged upon your demonstrated understanding of PID control and practical implementation constraints, and the quality of your solution.
Simply P controller
The most basic P controller with kp=10 could make the car turn back to the roughly initial orientation after manually turning the car.
However, there is a noticeable difference between the initial orientation direction and the fianl orientation direction (about 6 degrees).
So, it is necessary for us to implement a integrator to eliminate this difference.
PI Controller
Here below shows the result after adding an integrator with ki = 1, and the final error after each turning back is remaining within +-2 degrees, which is totally acceptable for us.
Because the result of the PI controller is good enough, I think it is not necessary to implement an extra D controller, so the PI controller is my final version.
And the demo result is attached here:
From the video above we could know that the car could turn back to the inital orientation direction no matter which direction we manually turn the car. And the error is within 2 degrees.
Change the set point
To test whether the car could change the set point and still remain stable and convergent, I wrote the code below in the PI contoller part.
As the code above shows, I make the overall process last for 10 seconds, and the setpoint will add 90 degrees when the program has already ran for 5 seconds.
Here below is the figure of setpoint over time:
And here is the yaw returned from the IMU. There is a lack off when we changed the yaw at 5s, the process of changing yaw from 0 to 90 degrees started at about 6 seconds.
Here below is the video demostration:
The result is quite good, there is no divergence observed in the whole process.
Implement wind-up protection for your integrator. Argue for why this is necessary (you may for example demonstrate how your controller works reasonably independent of floor surface). Demonstrate your system with and without wind-up protection.
Here I wrote the wind-up protection for the integrator, limiting the integrator within -50~50, the code is attached here:
And here is the yaw response after adding a wind-up:
Compared to the non-wind-up code, there are some fluctuations occured after winding up, indicating the wind-up is not necessary for this task since the fraction of wheel rotation is large enough to avoid the overshoot.